//
//  RecommendViewController.m
//  CaiPiao
//
//  Created by apple on 2018/5/21.
//  Copyright © 2018年 apple. All rights reserved.
//




#import "RecommendViewController.h"
#import "RecommentView.h"

@interface RecommendViewController ()
@property (weak, nonatomic) IBOutlet UIView *buttonBoxView;

@property (weak, nonatomic) IBOutlet RecommentView *numberBox_1;
@property (weak, nonatomic) IBOutlet RecommentView *numberBox_2;
@property (weak, nonatomic) IBOutlet RecommentView *numberBox_3;

@property (nonatomic,retain)NSString* numberString_1;
@property (nonatomic,retain)NSString* numberString_2;
@property (nonatomic,retain)NSString* numberString_3;

@end

@implementation RecommendViewController{
    NSString* selectedID;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"今日推荐";
    selectedID = @"4";
    [self numberBoxAddNumber];
}

-(void)numberBoxAddNumber{
    [self.numberBox_1 addNumberToNumberBoxViewsWith:selectedID andCallBack:^(NSString *numberString) {
        self.numberString_1 = numberString;
    }];
    [self.numberBox_2 addNumberToNumberBoxViewsWith:selectedID andCallBack:^(NSString *numberString) {
        self.numberString_2 = numberString;
    }];
    [self.numberBox_3 addNumberToNumberBoxViewsWith:selectedID andCallBack:^(NSString *numberString) {
        self.numberString_3 = numberString;
    }];
}

#pragma mark - 选择类型
- (IBAction)styleAction:(UIButton *)sender {
    for (UIButton* button in self.buttonBoxView.subviews) {
        [button setTitleColor:[UIColor colorWithRed:(145/255.0) green:(145/255.0) blue:(145/255.0) alpha:1] forState:UIControlStateNormal];
    }
    [sender setTitleColor:[UIColor colorWithRed:(255/255.0) green:(63/255.0) blue:(63/255.0) alpha:1] forState:UIControlStateNormal];
    switch (sender.tag) {
        case 101:
            selectedID = @"4";
            break;
        case 102:
            selectedID = @"3";
            break;
        case 103:
            selectedID = @"6";
            break;
        case 104:
            selectedID = @"5";
            break;
        case 105:
            selectedID = @"9";
            break;
        case 106:
            selectedID = @"7";
            break;
        default:
            break;
    }
    [self numberBoxAddNumber];
}

#pragma mark - 换一换
- (IBAction)changeAction:(id)sender {
    [self numberBoxAddNumber];
}

#pragma mark - 下一步
- (IBAction)nextAction:(id)sender {
//    NSLog(@"%@",self.numberString_1);
//    NSLog(@"%@",self.numberString_2);
//    NSLog(@"%@",self.numberString_3);
//
//    NSLog(@"%@",selectedID);
    if ([OpenLoginManager openLoginPageWithController:self]) {
    return;
    }
    CollectionNumberModel *model1 = [CollectionNumberModel setModelWithType:selectedID number:self.numberString_1];
    CollectionNumberModel *model2 = [CollectionNumberModel setModelWithType:selectedID number:self.numberString_2];
    CollectionNumberModel *model3 = [CollectionNumberModel setModelWithType:selectedID number:self.numberString_3];
    [CollectionNumberManager collectionNumberWithArray:@[model1,model2,model3]];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
